

//声明时间数组，从第二个开始，循环算法<=
//声明偶数(烂柯山晟江)时间
var evenNum=[9,14,17,23,30,34,38,42,48,52,56]
//声明奇数(百溪楚州)时间
var oddNum=[4,8,11,14,22,26,35,34,40,45,50]

//偶数遍历
function evenFind(a) {
    for (let i = 0; i < evenNum.length; i++) {
        if (a<=evenNum[i]-1) {
        return i
    }  
    }
    return evenNum.length+1 
}

//奇数遍历
function oddFind(a) {
    for (var i = 0; i < oddNum.length; i++) {
        if (a<=oddNum[i]-1) {
        return i
    }   
    }
    return oddNum.length+1
}

//顺序转换算法
function getOrder() {
    //获取小时
    var nowHour=getTime()[0]
    //获取分钟
    var nowMin=getTime()[1]
    // document.getElementById('nowAction').innerText=nowMin
    setTimeout(getOrder,100)

    if (nowHour&1==1) {
        t=oddFind(nowMin)
    } else {
        t=evenFind(nowMin)
    }
    return t
}

//处理字数
function setTime(num){
    if (num>9) {
        num =num 
    } else {
        num ="0"+num
    }
    return num 
}
//判断奇偶

//获取 返回时间
function getTime(){
    let now=new Date()
    let h=now.getHours(),m=now.getMinutes(),s=now.getSeconds()

     //替换内容
     h=setTime(h)
     m=setTime(m)
     s=setTime(s)

    let resault=h+":"+m+":"+s
     document.getElementById('getTime').innerText=resault
    //1S返回
    setTimeout(getTime,500)
    return [now.getHours(),m=now.getMinutes(),s=now.getSeconds()]
}
//返回偶数(烂柯山晟江)事件

//返回奇数(百溪楚州)事件
function setAction() {
    //获取小时
    var nowHour=getTime()[0]
    //获取顺序
    var key=getOrder()
    var nowAction,nowPlace
    setTimeout(setAction,100)
    console.log(key)
    if (nowHour & 1 == 1) {
        if (key<7) {
            nowPlace="百溪"
        } else {
            nowPlace="楚州"
        }
        switch (key) {//奇数序列
            case 0:
                nowAction = "黄崎港打怪"
                break;
            case 1:
                nowAction="北侧山坡田地收集/打怪"
                break;
            case 2:
                nowAction="镇海阁烧船"
                break;
            case 3:
                nowAction="黄崎港打怪"
                break;
            case 4:
                nowAction = "船厂东村跟随"
                break;
            case 5:
                nowAction = "流木村劝阻/打怪"
                break;
            case 6:
                nowAction = "斧斤帮二连"
                break;
            case 7:
                nowAction = "山阳村打怪"
                break;
            case 8:
                nowAction = "末口镇保护10波"
                break;
            case 9:
                nowAction = "盐场西门跟随"
                break;
            case 10:
                nowAction = "南辕镇北Boss"
                break;
            default:
                nowAction = "永宁寺Boss"
                break;
        }
    } else {
        if (key < 5) {
            nowPlace = "烂柯山"
        } else {
            nowPlace = "晟江"
        }
        switch (key) {//偶数序列
            case 0:
                nowAction = "溪明镇三连"
                break;
            case 1:
                nowAction = "凌天塔Boss"
                break;
            case 2:
                nowAction = "鬼市Boss"
                break;
            case 3:
                nowAction = "凌天寺东二连"
                break;
            case 4:
                nowAction = "溪明镇西三连"
                break;
            case 5:
                nowAction = "黄槲镇屋顶小怪"
                break;
            case 6:
                nowAction = "白菰里桥头Boss"
                break;
            case 7:
                nowAction = "白菰里水池Boss"
                break;
            case 8:
                nowAction = "白菰里北跟随"
                break;
            case 9:
                nowAction = "正觉寺劝阻/打怪"
                break;
            case 10:
                nowAction = "白菰里桥头Boss"
                break;
            default:
                nowAction = "白菰里水池Boss"
                break;
        }
        
    }
    document.getElementById('nowAction').innerText = nowAction
    document.getElementById('nowPlace').innerText = nowPlace

}
//监听事件
window.addEventListener('load',getTime)
window.addEventListener('load',getOrder)
window.addEventListener('load',setAction)